function initinputValue(){
	$(".txa").focus(function(){
		this.select();	
	});
}

//自动加“/”
function splitport(obj){
	var sport=obj.value.toUpperCase();
	
	if(sport=="XXX" || sport.length<4){
		obj.value=sport;
		return;
	}
	
	var dport="";
	sport=sport.replace(/\//g,"");
	while(sport!=""){
		dport+=sport.substr(0,3)+"/";
		sport=sport.substr(3,sport.length-3);
	}
	obj.value=dport;
	
}

function pushValueBySelect(SelObj, TextObj) {
	
	var sText=TextObj.value;
	if(sText.indexOf("/")==-1){sText+="/";}
	
	for(var i=0;i<SelObj.options.length;i++) {
		var opt=SelObj.options[i];
		if (opt.selected) {
			if (opt.value=="XXX") {
				TextObj.value = "XXX";
				return;
			}
			if(sText.indexOf(opt.value)==-1){
				sText += opt.value+"/";
			}
				
		}
	}
	if (sText!="") {
		TextObj.value =sText;
	} else {
		TextObj.value = "";
	}
}

function initAirportSel (SelObj) {
	var arCities = airportName.split("@");
	arCities.sort();
	SelObj.options.length = arCities.length-1;
	SelObj.options(0).value = "XXX";
	SelObj.options(0).text = "X-ALL";
	for(var i=2;i<arCities.length-1;i++) {
		var arV = arCities[i].split("||");
		SelObj.options(i-1).value = arV[1];
		SelObj.options(i-1).text = arV[0].substring(0,1)+"-"+arV[0];
	}
}
function UnselectAllSel ( SelObj, TextObj ) {
	SelObj.value = "";
	TextObj.value = "";
	return false;
}
function SelectAllSel ( SelObj, TextObj ) {
	SelObj.options(0).selected=true;
	TextObj.value = "XXX";
	return false;
}

var MaxI=0


//增加模板行
function addmodelbyIndex1(index,iMaxI){
	var objtb	=gd$("tbGroupPolicy_"+index);
	var objtbM=gd$("tbModel_"+index);
	var newtr=objtb.insertRow(-1);
	var rowlength=objtb.rows[0].cells.length;
	newtr.align="center";
	for(var i=0;i<rowlength;i++){
		var td=newtr.insertCell(-1);
		var html=objtbM.rows[0].cells[i].innerHTML;
		html=html.replace(/REPLACE_INDEX/g,iMaxI);
		td.innerHTML=html;
	}
}

function delnomalclass(obj){
	if (document.getElementsByName("Discount[]").length==2){
		alert("At least one policy");	
		return false;
	}else{
		return deletethisrow(obj);		
	}
	
}

function delnomaltax(obj){
	if (document.getElementsByName("Tax[]").length==2){
		alert("At least one Tax");	
		return false;
	}else{
		return deletethisrow(obj);		
	}
	
}

//删除当前行
function deletethisrow(obj){
	$(obj.parentNode.parentNode).remove();
	return false;
}

//检查机票政策递交
function Checkairpolicy_1(obj){
	//基本判断
	var blCheck,blRound1,blRound2;
	blCheck=true;
	
	if(!CheckFormSubmit(obj)){
		blCheck=false;
	}
	
	
	return blCheck;
}

//设置适用舱位T
function setClassPolicyT(iMaxI,jValue){	
	gd$("txSinDiscount_"+iMaxI).value=jValue.ClassCode;
	gd$("txDiscount_"+iMaxI).value=jValue.Discount;
	gd$("txFare_"+iMaxI).value=jValue.Fare;
	
	gd$("txTaxFee_"+iMaxI).value=jValue.TaxFee;
	gd$("txStopDay_"+iMaxI).value=jValue.StopDay;
	gd$("txClassNote_"+iMaxI).value=jValue.ClassNote;
	gd$("txMix_"+iMaxI).value=jValue.MixClass;

	if(jValue.MixClass=="1")
	{
		gd$("chkMix_"+iMaxI).checked=true;
	}else
	{
		gd$("chkMix_"+iMaxI).checked=false;	
	}
	
}
//设置混合舱位
function setMix(obj)
{
	var txid=obj.id.replace("chk","tx");
	var objtx=gd$(txid);
	if(obj.checked)
	{
		objtx.value="1";
	}else
	{
		objtx.value="0";
	}
}

//设置适用舱位T
function setTaxPolicyT(iMaxI,jValue){	
	gd$("sel_air_"+iMaxI).value=jValue.Airline;
	gd$("txTax_"+iMaxI).value=jValue.Tax;
	gd$("txChildTax_"+iMaxI).value=jValue.ChildTax;
}